## Sid Meier's Civilization 4
# < edited by the ViSa Modpack Team >

from CvPythonExtensions import *
from CvTechLeakScreensEnums import *

import PyHelpers
import CvUtil
import ScreenInput
import CvScreenEnums
import string
import CvViSaTechleakEventManager



# globals
gc = CyGlobalContext()
localText = CyTranslator()


class CvTechLeakSplashScreen:
	"Tech Leak Splash screen on first occurance"
	
	def __init__(self):

		
		self.X_SCREEN = 255
		self.Y_SCREEN = 40
		self.W_SCREEN = 515
		self.H_SCREEN = 570
		self.Z_BACKGROUND = -1.1
		self.Z_CONTROLS = self.Z_BACKGROUND - 0.2
		self.DZ = -0.2
		

		self.iMarginSpace = 15

		
		self.Y_TITLE = self.Y_SCREEN + 25
		
		self.W_PORTRAIT = 460
		self.H_PORTRAIT = 460
				
		self.X_EXIT = self.X_SCREEN + self.W_SCREEN/2 - 66
		self.Y_EXIT = self.Y_SCREEN + self.H_SCREEN - 50
		self.W_EXIT = 120
		self.H_EXIT = 30

		self.Y_MULTI_TEXT_SCREEN = self.Y_SCREEN + 440
		self.X_MULTI_TEXT_SCREEN = self.X_SCREEN + 22
		self.W_MULTI_LINE_SCREEN = int(self.W_SCREEN / 1.1)
		self.H_MULTI_TEXT_SCREEN = self.H_SCREEN - self.Y_MULTI_TEXT_SCREEN 
		
			
	
	def interfaceScreen (self, iPlayer):

		screen = CyGInterfaceScreen( TECHLEAK_SPLASH_SCREEN_ID, CvScreenEnums.TECH_LEAK_SPLASH_SCREEN)
		screen.addPanel(TECHLEAK_SPLASH_PANEL_ID, "", "", true, true,
			self.X_SCREEN, self.Y_SCREEN, self.W_SCREEN, self.H_SCREEN, PanelStyles.PANEL_STYLE_MAIN)
		
		screen.showWindowBackground(True)
		screen.setSound("AS2D_NEW_ERA")
		screen.showScreen(PopupStates.POPUPSTATE_MINIMIZED, False)
		screen.setDimensions(screen.centerX(0), screen.centerY(0), 1024, 768)
		screen.setRenderInterfaceOnly(False)

		
		# Header...choose which header-text to be displayed
		if ( gc.getPlayer(iPlayer).getTechLeakRecieved() and not gc.getPlayer(iPlayer).getTechLeakSend() ):
			szHeader = localText.getText("TXT_KEY_TECHLEAK_INFO_HEADER_RECIEVED", ())
		if ( gc.getPlayer(iPlayer).getTechLeakSend() and not gc.getPlayer(iPlayer).getTechLeakRecieved() ):
			szHeader = localText.getText("TXT_KEY_TECHLEAK_INFO_HEADER_LEAK", ())
		if ( gc.getPlayer(iPlayer).getTechLeakSend() and gc.getPlayer(iPlayer).getTechLeakRecieved() ):
			szHeader = localText.getText("TXT_KEY_TECHLEAK_INFO_HEADER_LEAK_RECIEVED", ())

		# set the main panel and top panel text                        
		screen.setText(TECHLEAK_SPLASH_TEXT_ID, "Background", szHeader, CvUtil.FONT_CENTER_JUSTIFY,
			       self.X_SCREEN + self.W_SCREEN / 2, self.Y_TITLE, 0, FontTypes.TITLE_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1)
		
		screen.setButtonGFC( TECHLEAK_SPLASH_EXIT_ID, "Ok", "", self.X_EXIT, self.Y_EXIT, self.W_EXIT, self.H_EXIT,
				    WidgetTypes.WIDGET_CLOSE_SCREEN, -1, -1, ButtonStyles.BUTTON_STYLE_STANDARD )

		# add the picture
		screen.addDDSGFC( TECHLEAK_SPLASH_PICTURE_ID, "Art/TechLeak/TechLeak.dds", self.X_SCREEN + 27, self.Y_SCREEN + 50, self.W_PORTRAIT,
				 self.H_PORTRAIT, WidgetTypes.WIDGET_GENERAL, -1, -1 )

		# set the text for the discription of the picture
		szInfoText = "<color=0,0,0,0>" + u"<font=2b>" + localText.getText("TXT_KEY_TECHLEAK_INFO", ()) + u"</font>"

		# add text to the picture
		screen.addMultilineText( TECHLEAK_SPLASH_MULTI_TEXT_ID, szInfoText, self.X_MULTI_TEXT_SCREEN, self.Y_MULTI_TEXT_SCREEN, self.W_MULTI_LINE_SCREEN,
					self.H_MULTI_TEXT_SCREEN, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_CENTER_JUSTIFY)


		return 0
		
	# Will handle the input for this screen...
	def handleInput (self, inputClass):
		return 0

	def update(self, fDelta):
		return
